<?php
namespace Admin\Model;
use Think\Model;
use Common\Common\ConstantUtil;

class ClassifyModel extends Model {

    protected $tableName = 'classify';

    public function getClassify() {
        return $this->where(["status"=>ConstantUtil::GLOBAL_TRUE,"classify"=>ConstantUtil::SYSTEM_ADMIN])->order("id desc")->select();
    }

    public  function getClassifyModules() {
        $result = [];
        $classify = $this->getClassify();
        foreach($classify as $val) {
            $modules = M("modules")->where(["classify_id"=>$val["id"],"status"=>ConstantUtil::GLOBAL_TRUE])->select();
            foreach($modules as $key => $val2) {
                $modules_func = M("modules_func")->where(["modules_id"=>$val2["id"],"status"=>ConstantUtil::GLOBAL_TRUE])->select();
                $modules[$key]["modules_func_list"] = $modules_func;
            }
            $val["modules_list"] = $modules;
            $result[] = $val;
        }
        return $result;
    }



}
